package KVRMIService;

import java.rmi.*;

public class KVServer {

	public static void main (String[] args) {
		// Check for the correct number of arguments to be passed in
	    if (args.length != 1) {
	        // Print out an error message to the screen
	        System.out.println("Error: Incorrect number of input parameters!");
	        // Call function to display usage
	        DisplayUsage();
	        // Exit the program
	        System.exit(0);
	    }
	    
	    // TODO: Read in the topology file and extract each node's information
	    
		
	    // Try to create the bindings for each KVStore object (one per node)
		try {
			// Bind the name of the KVStore that can be accessed
			Naming.rebind("KVStore", new KVStore());
		}
		catch (Exception e) {
			System.out.println("KVServer failed: " + e);
		}
	}
	
	/**
	 * Function to display the usage
	 */
	public static void DisplayUsage() {
	    System.out.println("\nKVStore - Used to launch the kv stores (for each node)\n");
	    System.out.println("\tUsage: ./KVServer <topology-ini>");
	}
}
